package com.jane.adapter.homepageadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jane.adapter.MyBaseAdapter;
import com.jane.bean.HomePageGridViewBean;
import com.jane.gzzb.R;
import com.jane.utils.Utils;

import java.util.List;

/**
 * Created by Administrator on 2016/11/15.
 */

public class NotLiveAdapter extends MyBaseAdapter {
    //申明
    private Context mContext;
    private LayoutInflater mInflater;

    public NotLiveAdapter(Context context, List Data) {
        super(Data);
        mContext = context;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_list_notlive, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        //获取数据
        HomePageGridViewBean data = (HomePageGridViewBean) getItem(position);
        holder.commentator.setText(data.getCommentator());
        holder.name.setText(data.getName());
        Utils.loadCircleImage(holder.rawcommentatorimage, data.getRawcommentatorimage());
        return convertView;
    }

    public static class ViewHolder {
        TextView name, commentator;
        ImageView rawcommentatorimage;

        public ViewHolder(View convertView) {
            name = (TextView) convertView.findViewById(R.id.item_list_notlive_sourcename);
            commentator = (TextView) convertView.findViewById(R.id.item_list_notlive_title);
            rawcommentatorimage = (ImageView) convertView.findViewById(R.id.item_list_notlive_rawcommentatorimage);
        }
    }
}
